package actions;

import gui.GUIWindow;


public class SysTrayActionManager {

	private GUIWindow owner;
	
	private StatusAction statusAction = null;	
	private ExitAction exitAction = null;;
	private SettingsAction settingsAction = null;
	private StartAction startAction = null;
	private StopAction stopAction = null;
	private AboutAction aboutAction = null;
	
	
	public SysTrayActionManager(GUIWindow owner) {
		this.owner = owner;
		
		initializeActions();
	}
	
	private void initializeActions() {
		statusAction  = new StatusAction(owner);
		exitAction = new ExitAction(owner);
		settingsAction = new SettingsAction(owner);
		startAction = new StartAction(owner);
		stopAction = new StopAction(owner);
		aboutAction = new AboutAction(owner);
	}

	
	
	// Getters
	
	public AboutAction getAboutAction() {
		return aboutAction;
	}

	public ExitAction getExitAction() {
		return exitAction;
	}

	public SettingsAction getSettingsAction() {
		return settingsAction;
	}

	public StartAction getStartAction() {
		return startAction;
	}

	public StatusAction getStatusAction() {
		return statusAction;
	}

	public StopAction getStopAction() {
		return stopAction;
	}

	
	public void setStartedRights() {
		startAction.setEnabled(false);
		stopAction.setEnabled(true);
		settingsAction.setEnabled(false);
	}
	
	
	public void setStoppedRights() {
		startAction.setEnabled(true);
		stopAction.setEnabled(false);
		settingsAction.setEnabled(true);
	}
	
	
	public void setSettingsRights(boolean flag) {
		if ( flag == true ) {
			if (owner.getApplication().getRlmServerReference() != null) {
				if ( owner.getApplication().getRlmServerReference().isStarted() )
					stopAction.setEnabled(flag);
				else
					startAction.setEnabled(flag);
			}
			else {
				startAction.setEnabled(flag);
			}
		}
		else {
			startAction.setEnabled(flag);
			stopAction.setEnabled(flag);			
		}
		settingsAction.setEnabled(flag);
		aboutAction.setEnabled(flag);
		exitAction.setEnabled(flag);
	}
	
}
